 /*
 * @lc app=leetcode.cn id=589 lang=cpp
 *
 * [589] N 叉树的前序遍历
 */
#include <iostream>
#include <algorithm>
#include <vector>
#include <string>
#include <cmath>

using namespace std; 
// @lc code=start
/*
// Definition for a Node.
class Node {
public:
    int val;
    vector<Node*> children;

    Node() {}

    Node(int _val) {
        val = _val;
    }

    Node(int _val, vector<Node*> _children) {
        val = _val;
        children = _children;
    }
};
*/

class Solution {
public:
    vector<int> ret;
    void preOrder(Node* root) {
        if(!root) {
            return ;
        }
        ret.push_back(root->val);
        for(auto x: root->children) {
            preOrder(x);
        }
    }
    vector<int> preorder(Node* root) {
        preOrder(root);
        return ret;
    }
};
// @lc code=end

